{eq name="Request.action" value="edit"}
{Data:article id="request" var="vo"}
{else /}
{/eq}
<style>
	body .layui-form-item .layui-input-inline {
		float: left;
		width: 190px;
		margin-right: 10px;
	}
	.selectCom{position:absolute;right:0;top:0;}
    .attachs:after{content:' ';clear: both;}
    .attach{width:210px;height:335px;display:inline-block;margin:0 10px 10px 0;}
    .attach .layui-progress{display:none;}
    .attach img{max-width:210px;max-height:297px;}
    .attach .img{width:210px;height:297px;background:#ddd;position: relative;overflow: hidden;}
    .attach .img p {position: absolute;top: 50%;left: 50%;margin: 0;padding: 0;}
    .attach .img img {position: absolute;top: -50%;left: -50%;display: block;}
    .attach .img img.hidden {visibility: hidden;position: static;}
    .attach .img .webuploader-pick{width:100%;height:100%;background:transparent;padding:0;}
    .attach .img .webuploader-pick:after{content:'\e681';font-family: layui-icon!important;line-height: 297px;font-size: 48px;}
</style>
<form action="__APP__/Loan/update.html" class="child-form page-list-form layui-form layui-form-pane" method="post">
	<div class="layui-tab layui-tab-brief">
		<ul class="layui-tab-title">
			<li lay-id="Base" class="layui-this">客户基本信息</li>
			<li lay-id="JingYing">经营信息</li>
			<li lay-id="LianXiRen">联系人信息</li>
			{eq name="Request.action" value="edit"}
			<li lay-id="Attach">附件信息</li>
			{/eq}
		</ul>
		<div class="layui-tab-content page-tab-content">
			<div class="layui-tab-item layui-show" id="Base">
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label">录入时间：</label>
						<div class="layui-input-inline">
							<INPUT TYPE="text" class="layui-input" name="date" id="date" value="{$vo.date|default=date('Y-m-d')}" lay-verify="required|date"/>
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">  业务员：</label>
						<div class="layui-input-inline">
							{html:select name="salesman" options=":Cache('Salesman')" first="--业务经理--" selected="vo['salesman']['id']" lay-verify="required"/}
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">进度：</label>
						<div class="layui-input-inline">{html:select name="step" options=":LinkageList('BorrowStep')" selected="vo['step']" class="Require" lay-verify="required"/}</div>
					</div>
				</div>

				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label">申请金额：</label>
						<div class="layui-input-inline"><INPUT TYPE="text" class="layui-input" name="money" value="{$vo.money}" lay-verify="money"></div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">核准金额：</label>
						<div class="layui-input-inline"><INPUT TYPE="text" class="layui-input" name="final_money" value="{$vo.final_money}" lay-verify="money" /></div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">贷款期限：</label>
						<div class="layui-input-inline"><INPUT TYPE="text" class="layui-input" name="month" value="{$vo.month}" lay-verify="n2-2" ></div>
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label">  申请人：</label>
						<div class="layui-input-inline">
							<INPUT TYPE="text" name="realname" value="{$vo.realname}" class="layui-input" lay-verify="realname"/>
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">身份证号：</label>
						<div class="layui-input-inline">
							<INPUT TYPE="text" name="extra[idcard]" value="{$vo.extra.idcard}" class="layui-input" lay-verify='identity'/>
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">　　性别：</label>
						<div class="layui-input-inline">
							{html:select name="extra[sex]" options=":LinkageList('Sex')" class="Require" selected="vo['extra']['sex']"/}
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">联系手机：</label>
						<div class="layui-input-inline"><INPUT TYPE="text" class="layui-input" name="extra[phone]" value="{$vo.extra.phone}" lay-verify='m'></div>
					</div>
				</div>

				<div class="layui-form-item">
					<!--div class="layui-inline">
						<label class="layui-form-label">住宅电话：</label>
						<div class="layui-input-inline"><INPUT TYPE="text" class="layui-input" name="extra[home_tel]" value="{$vo.extra.home_tel}"></div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">电子邮箱：</label>
						<div class="layui-input-inline"><INPUT TYPE="text" class="layui-input" name="extra[email]" value="{$vo.extra.email}" lay-verify='e' ignore="ignore"></div>
					</div-->
					<div class="layui-inline">
						<label class="layui-form-label">婚姻状况：</label>
						<div class="layui-input-inline">
							{html:select name="extra[marry]" options=":LinkageList('Marry')" lay-filter="marry" selected="vo['extra']['marry']" class="Require" /}
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">教育程度：</label>
						<div class="layui-input-inline">
							{html:select name="extra[edu]" options=":LinkageList('Edu')" selected="vo['extra']['edu']" class="Require" /}
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">户口所在地：</label>
						<div class="layui-input-inline">
							{html:select name="extra[hkszd]" options=":LinkageList('Szhk')" selected="vo['extra']['hkszd']" /}
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">本地居住：</label>
						<div class="layui-input-inline"><INPUT TYPE="text" class="Require layui-input" name="extra[bdjz]" value="{$vo.extra.bdjz}" lay-verify="n1-2"></div>
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label">本地房产：</label>
						<div class="layui-input-inline">
							{html:select name="extra[bdfc]" options=":LinkageList('Bdfc')" selected="vo['extra']['bdfc']" class="Require" /}
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">居住情况：</label>
						<div class="layui-input-inline">
							{html:select name="extra[jzzk]" options=":LinkageList('Jzzk')" selected="vo['extra']['jzzk']" class="Require" lay-verify='*'/}
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">居住地址：</label>
						<div class="layui-input-inline" style="width:515px;"><INPUT TYPE="text" class="layui-input" name="extra[home_addr]" value="{$vo.extra.home_addr}"></div>
					</div>
				</div>
				<div class="layui-form-item" id="PeiOuInfo">
					<div class="layui-inline">
						<label class="layui-form-label">配偶姓名：</label>
						<div class="layui-input-inline"><INPUT TYPE="text" class="layui-input" name="extra[mate_name]" lay-verify='z2-4' value="{$vo.extra.mate_name}">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">配偶手机：</label>
						<div class="layui-input-inline"><INPUT TYPE="text" class="layui-input" name="extra[mate_phone]" lay-verify='m' value="{$vo.extra.mate_phone}">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">配偶身份证：</label>
						<div class="layui-input-inline"><INPUT TYPE="text" class="layui-input" name="extra[mate_idcard]" lay-verify='idcard' value="{$vo.extra.mate_idcard}">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">配偶公司：</label>
						<div class="layui-input-inline"><INPUT TYPE="text" class="layui-input" name="extra[mate_com]" value="{$vo.extra.mate_com}">
						</div>
					</div>
				</div>
			</div>
			<div class="layui-tab-item" id="JingYing">
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label">经营项目：</label>
						<div class="layui-input-inline" style="width:600px;">
							<INPUT TYPE="text" class="layui-input" name="extra[com_name]" id="com_name" value="{$vo.extra.com_name}" autocomplete="off" placeholder="挂靠公司名称"  lay-verify='*'>
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">成立日期：</label>
						<div class="layui-input-inline"><INPUT TYPE="text" class="layui-input wDate" name="extra[com_date]" id="com_date" value="{$vo.extra.com_date}" lay-verify='*'></div>
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label">经营地址：</label>
						<div class="layui-input-inline" style="width:600px;"><INPUT TYPE="text" class="layui-input" name="extra[com_addr]" value="{$vo.extra.com_addr}" lay-verify='*' autocomplete="on"></div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">公司电话：</label>
						<div class="layui-input-inline"><INPUT TYPE="text" class="layui-input" name="extra[com_tel]" value="{$vo.extra.com_tel}"></div>
					</div>
				</div>
			</div>
			<div class="layui-tab-item" id="LianXiRen">
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label">联系人一：</label>
						<div class="layui-input-inline"><INPUT TYPE="text" class="layui-input" name="extra[sos_name1]" lay-verify='z2-4' value="{$vo.extra.sos_name1}"></div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">性别：</label>
						<div class="layui-input-inline">{html:select name="extra[sos_sex1]" options=":LinkageList('Sex')" selected="vo['extra']['sos_sex1']" class="Require" lay-verify='*'/}</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">关系：</label>
						<div class="layui-input-inline">
							<INPUT TYPE="text" class="layui-input" name="extra[sos_rela1]" value="{$vo.extra.sos_rela1}" lay-verify='*' list="sos_rela1" />
							<datalist id="sos_rela1">
								<option value="父亲">
								<option value="母亲">
								<option value="哥哥">
								<option value="弟弟">
								<option value="姐姐">
								<option value="妹妹">
								<option value="儿子">
								<option value="女儿">
							</datalist>
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">联系手机：</label>
						<div class="layui-input-inline"><INPUT TYPE="text" class="layui-input" name="extra[sos_phone1]" value="{$vo.extra.sos_phone1}" lay-verify='m'></div>
					</div>
					<!--div class="layui-inline">
						<label class="layui-form-label">联系座机：</label>
						<div class="layui-input-inline"><INPUT TYPE="text" class="layui-input" name="extra[sos_tel1]"></div>
					</div-->
				</div>

				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label">联系人二：</label>
						<div class="layui-input-inline"><INPUT TYPE="text" class="layui-input" name="extra[sos_name2]" value="{$vo.extra.sos_name2}" lay-verify='z2-4'></div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">性别：</label>
						<div class="layui-input-inline">{html:select name="extra[sos_sex2]" options=":LinkageList('Sex')" selected="vo['extra']['sos_sex2']" class="Require" lay-verify='*'/}</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">关系：</label>
						<div class="layui-input-inline">
							<INPUT TYPE="text" class="Require layui-input" name="extra[sos_rela2]" value="{$vo.extra.sos_rela2}" lay-verify='*' list="sos_rela2"/>
							<datalist id="sos_rela2">
								<option value="朋友">
								<option value="同学">
								<option value="同事">
							</datalist>
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">联系手机：</label>
						<div class="layui-input-inline"><INPUT TYPE="text" class="Require layui-input" name="extra[sos_phone2]" value="{$vo.extra.sos_phone2}" lay-verify='m'></div>
					</div>
					<!--div class="layui-inline">
						<label class="layui-form-label">联系座机：</label>
						<div class="layui-input-inline"><INPUT TYPE="text" class="layui-input" name="extra[sos_tel2]" ></div>
					</div-->
				</div>
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label">车牌号码：</label>
						<div class="layui-input-inline"><INPUT TYPE="text" class="layui-input" name="extra[car_no]" value="{$vo.extra.car_no}" value="粤B"></div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">车辆品牌：</label>
						<div class="layui-input-inline"><INPUT TYPE="text" class="layui-input" name="extra[car_brand]" value="{$vo.extra.car_brand}" autocomplete="on"></div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">车辆型号：</label>
						<div class="layui-input-inline"><INPUT TYPE="text" class="layui-input" name="extra[car_model]" value="{$vo.extra.car_model}" autocomplete="on"></div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">车辆信息：</label>
						<div class="layui-input-inline"><INPUT TYPE="text" class="layui-input" name="extra[car_info]" value="{$vo.extra.car_info}"></div>
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label">有线GPS编号：</label>
						<div class="layui-input-inline"><INPUT TYPE="text" class="layui-input" name="extra[gps][0]" value="{$vo['extra']['gps'][0]}"></div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">无线GPS编号：</label>
						<div class="layui-input-inline"><INPUT TYPE="text" class="layui-input" name="extra[gps][1]" value="{$vo['extra']['gps'][1]}"></div>
					</div>
				</div>
				<div class="form-item cf">
					<label class="layui-form-label">借款说明：</label>
					<div class="layui-input-inline">
						<textarea name="remark" id="" cols="200" rows="10" class="layui-textarea">{$vo.remark}</textarea>
					</div>
				</div>
			</div>
			{eq name="Request.action" value="edit"}
			<div class="layui-tab-item" id="Attach">
				<div class="attachs">
				</div>
				<div style="text-align: right;"><button type="button" class="layui-btn layui-btn layui-btn-normal" id="AddAttach">添加附件</button></div>
			</div>
			{/eq}
			<div class="layui-form-item">
				<div class="layui-input-block">
					<button type="submit" class="layui-btn" lay-submit="" lay-filter="formSubmit">提交</button>
				</div>
			</div>
			<input type="hidden" name="id" value="{$vo.id}" />
		</div>
	</div>
</form>
<script>
	layui.use(['jquery','form', 'layedit', 'laydate','element','suggest'], function(){
		var form = layui.form,
			layer = layui.layer,
			$ = layui.jquery,
			layedit = layui.layedit,
			laydate = layui.laydate,
			element = layui.element,
			suggest = layui.suggest,
			showofhide = function(value){
				if(value=='2'){
					$('#PeiOuInfo').show();
				}else{    		
					$('#PeiOuInfo').hide();
				}  				
			};
		form.on('select(marry)', function(data){
			showofhide(data.value);
		});
		showofhide($('[name=marry]').val());    

		laydate.render({
			elem: '#date'
		});
		laydate.render({
			elem: '#com_date'
		});        
		$('#com_name').suggest({
			source: '__APP__/Linkcom/getList.html',
			callback:function(a){
				$('[name=com_date]').val($(a).attr('data-date'));
				$('[name=com_addr]').val($(a).attr('data-address'));
			}
		});
		var maodian = window.location.href.split('#')[1];
		try{
			$('li[lay-id='+maodian+']').trigger('click');
		}catch(e){}
		/**/

		{eq name="Request.action" value="edit"}
        var options=['按揭申请表','银行征信','鹏元征信','手持照片','身份证复印件','驾驶证','营业执照','合格证','登记证书'];
        var optionsHtml = '';
        for (var i = 0; i < options.length; i++) {
        	optionsHtml+='<option>'+options[i]+'</option>';        	
        }
        function initupload(){
            $('.attachs .attach .img').each(function(k,v){
                if(!$(v).hasClass('rendered')){
                    $(v).addClass('rendered');
                    var uploader = WebUploader.create({
                        dnd :v,
                        disableGlobalDnd : true,
                        swf: 'https://cdn.staticfile.org/webuploader/0.1.5/Uploader.swf',
                        server: ADMIN_PATH +'/Attach/upload.html',
                        pick: v,
                        paste:document.body,
                        accept:{
                            title:'图片文件',
                            extensions:'gif,jpg,jpeg,bmp,png',
                            mimeTypes:'image/*',
                        },
                        formData :{_ajax:1},
                        auto:true,
                        compress:{
                            width: 1500,
                            //height: 1600,
                            // 图片质量，只有type为`image/jpeg`的时候才有效。
                            quality: 90,
                            // 是否允许放大，如果想要生成小图的时候不失真，此选项应该设置为false.
                            allowMagnify: false,
                            // 是否允许裁剪。
                            crop: false,
                            // 是否保留头部meta信息。
                            preserveHeaders: true,
                            // 如果发现压缩后文件大小比原来还大，则使用原来图片
                            // 此属性可能会影响图片自动纠正功能
                            noCompressIfLarger: true,
                            // 单位字节，如果图片大小小于此值，不会采用压缩。
                            compressSize: 1024
                        },
                        // 不压缩image, 默认如果是jpeg，文件上传前会压缩一把再上传！
                        resize: false
                    });
                    uploader.on( 'fileQueued', function( file ) {
                        var li = '<p><img src="" alt="" /><img src="" alt="" class="hidden" /></p>';
                        $(v).find('.webuploader-pick').html(li);
                        if(file.type.substring(0,5)=='image'){
                            uploader.makeThumb( file, function( error, src ) {
                                if ( error ) {
                                    console.info('不能预览');
                                    return;
                                }
                                $(v).find('.webuploader-pick img').attr( 'src', src );
                            }, 210, 297);                           
                        }
                    });
                    // 文件上传过程中创建进度条实时显示。
                    uploader.on( 'uploadProgress', function( file, percentage ) {
                        var p = $(v).parent().find('.layui-progress');
                        p.show();
                        layui.element.progress(p.attr('lay-filter'), percentage * 100 + '%');
                    });
                    uploader.on('uploadSuccess', function(file,data) {
                        var data=$.parseJSON(data['_raw']);
                        //$(v).parent().find(':hidden').val(data.id);
                        $(v).parent().find(':hidden').val(data.savepath +data.savename);
                        $(v).find('img').attr('src',data.savepath +data.savename);
                        //$(v).find(' .title').text(data.name);
                        $(v).parent().find('.layui-progress').hide();
                    });
                }
            });
        }
        function addFile(title,src){
        	console.info(title,src);
            var i = $('.attachs .attach').length;
            var $attach = $(['<div class="attach">'+
                '<div class="img"></div>'+
                '<div class="title"><select name="attachs['+i+'][title]" lay-filter="n'+i+'"><option>--请选择--</option>'+optionsHtml+'</select></div>'+
                '<div class="layui-progress" lay-filter="p'+i+'"><div class="layui-progress-bar" lay-percent="10%"></div></div>'+
                '<input type="hidden" name="attachs['+i+'][value]" value="">'+
            '</div>'].join(''));
            $attach.appendTo('.attachs');
            initupload();
            if(title){
                $attach.find('select').val(title);
            }
            if(src){
                $attach.find('input').val(src);
                var li = '<p><img src="'+src+'" alt="" /><img src="'+src+'" alt="" class="hidden" /></p>';
                $attach.find('.webuploader-pick').html(li);            
            }
            //layui.form.render('select','n'+i);
        }
        function initData(){
            var attachsData = $.parseJSON('{$vo.attachs|json_encode|raw}');
            if(attachsData){
	            console.info(attachsData);
	            for (var i = 0; i < attachsData.length; i++) {
	                addFile(attachsData[i]['title'],attachsData[i]['value']);                
	            }
	            layui.form.render('select');
            }else{
	            addFile('按揭申请表');
	            addFile('银行征信');
	            addFile('鹏元征信');
	            addFile('手持照片');
	            addFile('身份证复印件');
	            layui.form.render('select');
            }
        }
        //window.element = layui.element;
        if(typeof WebUploader == 'undefined'){
            $.getScript('https://cdn.staticfile.org/webuploader/0.1.5/webuploader.html5only.min.js',function(){
                initData();
                initupload();
            });
        }
        $('#AddAttach').on('click',function(){
            addFile();            
            layui.form.render('select');
        });
        {/eq}
	});
</script>